<template>
  <div class="imgshow">
      <transition-group tag = "div" class="imgbox">
      <div class="eachimg" v-for="item in imgidlist" :key ="item.id" @click="imgselected($event)" @mouseleave="cancleselected($event)">
        <div class="imgedit">
          <div>
            <span class="allscreen icon-enlarge2" @click="allscreen(imgidlist,item.id)"></span>
          </div>
        </div>
        <img :src="item.img" alt="">
      </div>
    </transition-group> 
  </div>
</template>

<script>
import "./style.css";
import {Openscreen} from "../../lib/js/allscreen.js"
export default {
    data(){
        return{
        imglist:[
            // {
            //   id:1,
            //   img:"http://localhost:3000/news/images/1612321026394.jpeg"
            // }
        ],
        readyfilelist:[]
        }
    },
    props:['imagelist'],
    created(){
        
    },
    methods:{
      allscreen(list,id){//全屏按钮
          let screen = new Openscreen(list,id);
          screen.init();
      },
      imgselected(e){
      var ele = e.currentTarget.firstChild;
      ele.style.opacity = "0.5";
      ele.style.left = '0px';
      },
      cancleselected(e){
      var ele = e.currentTarget.firstChild;
      ele.style.opacity = "0.5";
      ele.style.left = '-300px';
      },
      abc(){
        console.log(this.imgidlist);
      }
    },
    computed:{
      imgidlist(){
        return this.imagelist.map((item,index)=>{
          item.id = index+1;
          item.img = `http://localhost:3000/news/images/${item.name}`;
          return item;
        })
      }
    }
}
</script>

<style lang = 'less' scoped>
.imgshow{
  .v-enter,.v-leave-to{
    transform: translateX(50px);
    opacity: 1;
  }
  .v-enter-active,.v-leave-active{
    transition:  all  0.5s ease-in-out;
  }
  .imgbox{
    display: flex;
    width: 100%;
    flex-direction: row;
    align-items: flex-end;
    flex-wrap: wrap;
    img{
      width: 100%;
      height: 100%;
    }
    >div{     
      margin-bottom: 5px;
      box-sizing: border-box;
      width: 24%;
      height: 90px;
      margin-right: 1%!important;
      border: 1px solid #d9d9d9;
      border-radius: 3px;
      padding: 2px;
      position: relative;
      overflow: hidden;
      >.imgedit{
        width: 100%;
        height: 100%;
        background: rgb(0, 0, 0);
        position: absolute;
        left: -300px;
        /* left: 0; */
        top: 0;
        opacity:0;
        transition: all 0.5s ease-in-out;
        display: flex;
        align-items: center;
        >div{
          width: 100%;
          color: white;
          font-size: 6px;
          display: flex;
          justify-content: center;
          >span:first-of-type{
            margin-right: 10%;
          }
        }
      }
    }
    >div:last-of-type{
      margin-right: 0 !important;
    }
  }
}

</style>